using dnAnalytics.Math;
using NUnit.Framework;

namespace dnAnalytics.Tests.Math
{
    [TestFixture]
    public class ComplexMath_AtanhTest
    {
        [Test]
        public void Atanh()
        {
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, 1.19209289550780998537e-7)), new Complex(0.0, 1.19209289550780433848e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, -1.19209289550780998537e-7)), new Complex(0.0, -1.19209289550780433848e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, 5.0e-1)), new Complex(0.0, 4.63647609000806116214e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, -5.0e-1)), new Complex(0.0, -4.63647609000806116214e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, 1.0)), new Complex(0.0, 7.85398163397448309616e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, -1.0)), new Complex(0.0, -7.85398163397448309616e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, 2.0)), new Complex(0.0, 1.10714871779409050302), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, -2.0)), new Complex(0.0, -1.10714871779409050302), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, 8.388608e6)), new Complex(0.0, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(0.0, -8.388608e6)), new Complex(0.0, -1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, 0.0)), new Complex(1.19209289550781563226e-7, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, 0.0)), new Complex(-1.19209289550781563226e-7, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, 1.19209289550780998537e-7)), new Complex(1.1920928955077986916e-7, 1.19209289550782127914e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, -1.19209289550780998537e-7)), new Complex(1.1920928955077986916e-7, -1.19209289550782127914e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, 1.19209289550780998537e-7)), new Complex(-1.1920928955077986916e-7, 1.19209289550782127914e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, -1.19209289550780998537e-7)), new Complex(-1.1920928955077986916e-7, -1.19209289550782127914e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, 5.0e-1)), new Complex(9.53674316406248711098e-8, 4.63647609000810663688e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, -5.0e-1)), new Complex(9.53674316406248711098e-8, -4.63647609000810663688e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, 5.0e-1)), new Complex(-9.53674316406248711098e-8, 4.63647609000810663688e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, -5.0e-1)), new Complex(-9.53674316406248711098e-8, -4.63647609000810663688e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, 1.0)), new Complex(5.96046447753903580964e-8, 7.85398163397451862329e-1), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, -1.0)), new Complex(5.96046447753903580964e-8, -7.85398163397451862329e-1), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, 1.0)), new Complex(-5.96046447753903580964e-8, 7.85398163397451862329e-1), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, -1.0)), new Complex(-5.96046447753903580964e-8, -7.85398163397451862329e-1), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, 2.0)), new Complex(2.38418579101561500148e-8, 1.10714871779409163989), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, -2.0)), new Complex(2.38418579101561500148e-8, -1.10714871779409163989), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, 2.0)), new Complex(-2.38418579101561500148e-8, 1.10714871779409163989), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, -2.0)), new Complex(-2.38418579101561500148e-8, -1.10714871779409163989), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, 8.388608e6)), new Complex(1.69406589450857303051e-21, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.19209289550780998537e-7, -8.388608e6)), new Complex(1.69406589450857303051e-21, -1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, 8.388608e6)), new Complex(-1.69406589450857303051e-21, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.19209289550780998537e-7, -8.388608e6)), new Complex(-1.69406589450857303051e-21, -1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, 0.0)), new Complex(5.49306144334054845698e-1, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, 0.0)), new Complex(-5.49306144334054845698e-1, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, 1.19209289550780998537e-7)), new Complex(5.49306144334042213827e-1, 1.58945719401038988971e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, -1.19209289550780998537e-7)), new Complex(5.49306144334042213827e-1, -1.58945719401038988971e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, 1.19209289550780998537e-7)), new Complex(-5.49306144334042213827e-1, 1.58945719401038988971e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, -1.19209289550780998537e-7)), new Complex(-5.49306144334042213827e-1, -1.58945719401038988971e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, 5.0e-1)), new Complex(4.0235947810852509365e-1, 5.53574358897045251509e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, -5.0e-1)), new Complex(4.0235947810852509365e-1, -5.53574358897045251509e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, 5.0e-1)), new Complex(-4.0235947810852509365e-1, 5.53574358897045251509e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, -5.0e-1)), new Complex(-4.0235947810852509365e-1, -5.53574358897045251509e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, 1.0)), new Complex(2.38877861256859090363e-1, 8.47575660670829027131e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, -1.0)), new Complex(2.38877861256859090363e-1, -8.47575660670829027131e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, 1.0)), new Complex(-2.38877861256859090363e-1, 8.47575660670829027131e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, -1.0)), new Complex(-2.38877861256859090363e-1, -8.47575660670829027131e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, 2.0)), new Complex(9.6415620202996167238e-2, 1.12655644083482234874), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, -2.0)), new Complex(9.6415620202996167238e-2, -1.12655644083482234874), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, 2.0)), new Complex(-9.6415620202996167238e-2, 1.12655644083482234874), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, -2.0)), new Complex(-9.6415620202996167238e-2, -1.12655644083482234874), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, 8.388608e6)), new Complex(7.10542735760087564097e-15, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(5.0e-1, -8.388608e6)), new Complex(7.10542735760087564097e-15, -1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, 8.388608e6)), new Complex(-7.10542735760087564097e-15, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-5.0e-1, -8.388608e6)), new Complex(-7.10542735760087564097e-15, -1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, 1.19209289550780998537e-7)), new Complex(8.3177661667193456559, 7.85398193199770697311e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, -1.19209289550780998537e-7)), new Complex(8.3177661667193456559, -7.85398193199770697311e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, 1.19209289550780998537e-7)), new Complex(-8.3177661667193456559, 7.85398193199770697311e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, -1.19209289550780998537e-7)), new Complex(-8.3177661667193456559, -7.85398193199770697311e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, 5.0e-1)), new Complex(7.08303336014054020062e-1, 9.07887494960880386702e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, -5.0e-1)), new Complex(7.08303336014054020062e-1, -9.07887494960880386702e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, 5.0e-1)), new Complex(-7.08303336014054020062e-1, 9.07887494960880386702e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, -5.0e-1)), new Complex(-7.08303336014054020062e-1, -9.07887494960880386702e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, 1.0)), new Complex(4.0235947810852509365e-1, 1.01722196789785136772), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, -1.0)), new Complex(4.0235947810852509365e-1, -1.01722196789785136772), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, 1.0)), new Complex(-4.0235947810852509365e-1, 1.01722196789785136772), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, -1.0)), new Complex(-4.0235947810852509365e-1, -1.01722196789785136772), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, 2.0)), new Complex(1.73286795139986327354e-1, 1.17809724509617246442), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, -2.0)), new Complex(1.73286795139986327354e-1, -1.17809724509617246442), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, 2.0)), new Complex(-1.73286795139986327354e-1, 1.17809724509617246442), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, -2.0)), new Complex(-1.73286795139986327354e-1, -1.17809724509617246442), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, 8.388608e6)), new Complex(1.42108547152015998206e-14, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(1.0, -8.388608e6)), new Complex(1.42108547152015998206e-14, -1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, 8.388608e6)), new Complex(-1.42108547152015998206e-14, 1.57079620758560706845), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-1.0, -8.388608e6)), new Complex(-1.42108547152015998206e-14, -1.57079620758560706845), 9);
            //            TestHelper.TestLogRelativeError(ComplexMath.Atanh(new Complex(-2.0, 0.0)), new Complex(-5.49306144334054845698e-1, 1.57079632679489661923), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, 1.19209289550780998537e-7)), new Complex(5.4930614433405168773e-1, 1.57079628705846676897), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, -1.19209289550780998537e-7)), new Complex(5.4930614433405168773e-1, -1.57079628705846676897), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, 1.19209289550780998537e-7)), new Complex(-5.4930614433405168773e-1, 1.57079628705846676897), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, -1.19209289550780998537e-7)), new Complex(-5.4930614433405168773e-1, -1.57079628705846676897), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, 5.0e-1)), new Complex(5.00370000052531017442e-1, 1.42154686100180698026), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, -5.0e-1)), new Complex(5.00370000052531017442e-1, -1.42154686100180698026), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, 5.0e-1)), new Complex(-5.00370000052531017442e-1, 1.42154686100180698026), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, -5.0e-1)), new Complex(-5.00370000052531017442e-1, -1.42154686100180698026), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, 1.0)), new Complex(4.0235947810852509365e-1, 1.33897252229449356112), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, -1.0)), new Complex(4.0235947810852509365e-1, -1.33897252229449356112), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, 1.0)), new Complex(-4.0235947810852509365e-1, 1.33897252229449356112), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, -1.0)), new Complex(-4.0235947810852509365e-1, -1.33897252229449356112), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, 2.0)), new Complex(2.38877861256859090363e-1, 1.31122326967163514335), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, -2.0)), new Complex(2.38877861256859090363e-1, -1.31122326967163514335), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, 2.0)), new Complex(-2.38877861256859090363e-1, 1.31122326967163514335), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, -2.0)), new Complex(-2.38877861256859090363e-1, -1.31122326967163514335), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, 8.388608e6)), new Complex(2.84217094304019879509e-14, 1.57079620758560706846), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(2.0, -8.388608e6)), new Complex(2.84217094304019879509e-14, -1.57079620758560706846), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, 8.388608e6)), new Complex(-2.84217094304019879509e-14, 1.57079620758560706846), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-2.0, -8.388608e6)), new Complex(-2.84217094304019879509e-14, -1.57079620758560706846), 9);
            //            TestHelper.TestLogRelativeError(ComplexMath.Atanh(new Complex(-8.388608e6, 0.0)), new Complex(-1.19209289550781814689e-7, 1.57079632679489661923), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, 1.19209289550780998537e-7)), new Complex(1.19209289550781814689e-7, 1.57079632679489661923), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, -1.19209289550780998537e-7)), new Complex(1.19209289550781814689e-7, -1.57079632679489661923), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, 1.19209289550780998537e-7)), new Complex(-1.19209289550781814689e-7, 1.57079632679489661923), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, -1.19209289550780998537e-7)), new Complex(-1.19209289550781814689e-7, -1.57079632679489661923), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, 5.0e-1)), new Complex(1.19209289550781391172e-7, 1.5707963267948895138), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, -5.0e-1)), new Complex(1.19209289550781391172e-7, -1.5707963267948895138), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, 5.0e-1)), new Complex(-1.19209289550781391172e-7, 1.5707963267948895138), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, -5.0e-1)), new Complex(-1.19209289550781391172e-7, -1.5707963267948895138), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, 1.0)), new Complex(1.19209289550780120623e-7, 1.57079632679488240838), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, -1.0)), new Complex(1.19209289550780120623e-7, -1.57079632679488240838), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, 1.0)), new Complex(-1.19209289550780120623e-7, 1.57079632679488240838), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, -1.0)), new Complex(-1.19209289550780120623e-7, -1.57079632679488240838), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, 2.0)), new Complex(1.19209289550775038425e-7, 1.57079632679486819752), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, -2.0)), new Complex(1.19209289550775038425e-7, -1.57079632679486819752), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, 2.0)), new Complex(-1.19209289550775038425e-7, 1.57079632679486819752), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, -2.0)), new Complex(-1.19209289550775038425e-7, -1.57079632679486819752), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, 8.388608e6)), new Complex(5.96046447753904838278e-8, 1.57079626719025184384), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(8.388608e6, -8.388608e6)), new Complex(5.96046447753904838278e-8, -1.57079626719025184384), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, 8.388608e6)), new Complex(-5.96046447753904838278e-8, 1.57079626719025184384), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atanh(new Complex(-8.388608e6, -8.388608e6)), new Complex(-5.96046447753904838278e-8, -1.57079626719025184384), 9);
        }
    }
}